from PyQt5 import QtGui, QtWidgets, QtCore
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from mainwindow import Ui_MainWindow
import sys
import camera_infer


class MainWindowShow(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainWindowShow, self).__init__()
        self.setupUi(self)
        self.initUI()
        self.CallBackFunctions()

    def initUI(self):
        self.setWindowIcon(QIcon('icon.icns'))  # 给程序设置图标
        op = QtWidgets.QGraphicsOpacityEffect()  # # 设置透明度的值，0.0到1.0，最小值0是透明，1是不透明
        op.setOpacity(0.5)
        # window_pale = QtGui.QPalette()
        # window_pale.setBrush(self.backgroundRole(), QtGui.QBrush(QtGui.QPixmap("backgroundpic1.png")))
        # self.setPalette(window_pale)  # 给程序设置背景图
        self.setWindowTitle("基于疫情防控的口罩识别检测系统")
        self.DispLb = QtWidgets.QLabel(self.frame)
        self.DispLb.setPixmap(QtGui.QPixmap("h.png"))
        self.DispLb.setObjectName("DispLb")

    def discernment(self):
        QMessageBox.information(self, '提示', '如果有任何问题请联系我们，欢迎访问，团队邮箱：2477756486@qq.com', QMessageBox.Yes)

    def realtimetest(self):
        #pass
        args = camera_infer.parse_args()
        camera_infer.predict_video(args)

    def CallBackFunctions(self):  # 回调函数
        self.pushButton_5.clicked.connect(self.discernment)
        self.pushButton_4.clicked.connect(self.close)
        self.pushButton_3.clicked.connect(self.realtimetest)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon('icon.icns'))
    ui = MainWindowShow()
    ui.show()
    sys.exit(app.exec_())
